package com.example.demo25.controller;

import com.example.demo25.entity.Student;
import com.example.demo25.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    @PostMapping("/add")
    public String add(@RequestBody Student student) {
        Boolean boo = studentService.add(student);
        return boo ? "添加成功" : "添加失败";
    }

    @PostMapping("/delete")
    public String deleteStudent(Integer id) {
        return "";
    }

    @PostMapping("/modify")
    public String modifyStudent(@RequestBody Student student) {
        return "";
    }

    @PostMapping("/getstudent")
    public List<Student> getStudentByName(String studentName) {
        return studentService.getStudentByName(studentName);

    }
}
